using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace MagicAttributeTest
{
  public partial class UCInPlay : UserControl
  {
    public event GUIPermanentEventHandler evClickCard;
    public event GUIPermanentEventHandler evRightClickCard;

    public UCInPlay()
    {
      InitializeComponent();
    }
    public void UpdateGUI()
    {
      List<Permanent> permanents = Global.World.GetPermanents(MagicZone.InPlay);

      lbInPlay.Items.Clear();
      foreach (Permanent perm in permanents)
      {
        lbInPlay.Items.Add(perm);
      }
    }

    private void lbInPlay_MouseDoubleClick(object sender, MouseEventArgs e)
    {
      if (e.Button == MouseButtons.Left)
      {
        if (lbInPlay.SelectedItem != null)
        {
          Permanent permanent = (Permanent)lbInPlay.SelectedItem;
          if (evRightClickCard != null)
            evClickCard(permanent);
        }
      }
    }

    private void lbInPlay_MouseClick(object sender, MouseEventArgs e)
    {

    }

    private void lbInPlay_MouseUp(object sender, MouseEventArgs e)
    {
      if (e.Button == MouseButtons.Right)
      {
        if (lbInPlay.SelectedItem != null)
        {
          Permanent permanent = (Permanent)lbInPlay.SelectedItem;
          if (evRightClickCard != null)
            evRightClickCard(permanent);
        }
      }
    }
  }
}
